namespace KYO
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Data;
	using System.Data.SqlClient;
	using System.Text;
	
	
	public class tblProjectImage : Object
	{
		
		#region Static SQL String Memebers
		/// <remarks>This field represents the full SELECT string for the table tblProjectImage, with the WHERE clause.</remarks>
		internal static string _SQL_Select = "SELECT [ProjectImageID], [Title], [LinkUrl], [ImageUrl], [Type] FROM [dbo].[tblProjectImage] WHERE [ProjectImageID]=@ProjectImageID ";
		
		/// <remarks>This field represents the full INSERT INTO string for the table tblProjectImage.</remarks>
		internal static string _SQL_Insert = "INSERT INTO [dbo].[tblProjectImage] ([ProjectImageID], [Title], [LinkUrl], [ImageUrl], [Type]) VALUES([ProjectImageID], [Title], [LinkUrl], [ImageUrl], [Type]) ";
		
		/// <remarks>This field represents the full UPDATE string for the table tblProjectImage, with the WHERE clause.</remarks>
		internal static string _SQL_Update = "UPDATE [dbo].[tblProjectImage] SET [ProjectImageID] = @ProjectImageID, [Title] = @Title, [LinkUrl] = @LinkUrl, [ImageUrl] = @ImageUrl, [Type] = @Type WHERE [ProjectImageID]=@ProjectImageID ";
		
		/// <remarks>This field represents the DELETE string for the table tblProjectImage, with the WHERE clause.</remarks>
		internal static string _SQL_Delete = "DELETE FROM [dbo].[tblProjectImage] WHERE [ProjectImageID]=@ProjectImageID ";
		#endregion
		
		#region Tables Memebers
		/// <remarks>SQL Type:int - </remarks>
		private int _ProjectImageID;
		
		[DisplayName("Project Image ID")]
		[Category("Primary Key")]
		public int ProjectImageID
		{
			get
			{
				try
				{
					return _ProjectImageID;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ProjectImageID", err);
				}
			}
			set
			{
				try
				{
					_ProjectImageID = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ProjectImageID", err);
				}
			}
		}
		
		/// <remarks>SQL Type:nvarchar - </remarks>
		private string _Title;
		
		[DisplayName("Title")]
		[Category("Column")]
		public string Title
		{
			get
			{
				try
				{
					return _Title;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Title", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 100))
					{
						_Title = value;
					}
					else
					{
						throw new OverflowException("Error setting Title, Length of value is to long. Maximum Length: 100");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Title", err);
				}
			}
		}
		
		/// <remarks>SQL Type:nvarchar - </remarks>
		private string _LinkUrl;
		
		[DisplayName("Link Url")]
		[Category("Column")]
		public string LinkUrl
		{
			get
			{
				try
				{
					return _LinkUrl;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting LinkUrl", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 400))
					{
						_LinkUrl = value;
					}
					else
					{
						throw new OverflowException("Error setting LinkUrl, Length of value is to long. Maximum Length: 400");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting LinkUrl", err);
				}
			}
		}
		
		/// <remarks>SQL Type:nvarchar - </remarks>
		private string _ImageUrl;
		
		[DisplayName("Image Url")]
		[Category("Column")]
		public string ImageUrl
		{
			get
			{
				try
				{
					return _ImageUrl;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ImageUrl", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 400))
					{
						_ImageUrl = value;
					}
					else
					{
						throw new OverflowException("Error setting ImageUrl, Length of value is to long. Maximum Length: 400");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ImageUrl", err);
				}
			}
		}
		
		/// <remarks>SQL Type:nvarchar - </remarks>
		private string _Type;
		
		[DisplayName("Type")]
		[Category("Column")]
		public string Type
		{
			get
			{
				try
				{
					return _Type;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Type", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 40))
					{
						_Type = value;
					}
					else
					{
						throw new OverflowException("Error setting Type, Length of value is to long. Maximum Length: 40");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Type", err);
				}
			}
		}
		#endregion
		
		#region Public Methods
		public void Select(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblProjectImage._SQL_Select;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				SqlDataReader rs = Com.ExecuteReader();
				while(rs.Read())
				{
					AddFromRecordSet(rs);
				}
				rs.Close();
				Conn.Close();
				rs.Dispose();
				Com.Dispose();
				Conn.Dispose();
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Insert(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblProjectImage._SQL_Insert;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Update(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblProjectImage._SQL_Update;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Delete(string ConnectionString)
		{
			try
			{
				SqlConnection Conn = new SqlConnection(ConnectionString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = tblProjectImage._SQL_Delete;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public string[] GetSqlCommandStrings()
		{
			try
			{
				string[] CommStr = new string[4];
				CommStr[0] = "SELECT [ProjectImageID], [Title], [LinkUrl], [ImageUrl], [Type] FROM [dbo].[tblProjectImage] WHERE [ProjectImageID] = " + _ProjectImageID + "";
				CommStr[1] = "INSERT INTO [dbo].[tblProjectImage] ([ProjectImageID], [Title], [LinkUrl], [ImageUrl], [Type]) VALUES(" + _ProjectImageID + ", '" + _Title.Replace("'","''") + "', '" + _LinkUrl.Replace("'","''") + "', '" + _ImageUrl.Replace("'","''") + "', '" + _Type.Replace("'","''") + "')";
				CommStr[2] = "UPDATE [dbo].[tblProjectImage] SET [Title] = '" + _Title.Replace("'","''") + "' ,[LinkUrl] = '" + _LinkUrl.Replace("'","''") + "' ,[ImageUrl] = '" + _ImageUrl.Replace("'","''") + "' ,[Type] = '" + _Type.Replace("'","''") + "' WHERE [ProjectImageID] = " + _ProjectImageID + "";
				CommStr[3] = "DELETE FROM [dbo].[tblProjectImage] WHERE [ProjectImageID] = " + _ProjectImageID + "";
				return CommStr;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		#endregion
		
		#region Private Methods
		private void AddFromRecordSet(SqlDataReader rs)
		{
			try
			{
				// if value from the recordset, to the ProjectImageID field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("ProjectImageID")) == false))
				{
					ProjectImageID = rs.GetInt32(rs.GetOrdinal("ProjectImageID"));
				}
				// if value from the recordset, to the Title field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Title")) == false))
				{
					Title = rs.GetString(rs.GetOrdinal("Title"));
				}
				// if value from the recordset, to the LinkUrl field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("LinkUrl")) == false))
				{
					LinkUrl = rs.GetString(rs.GetOrdinal("LinkUrl"));
				}
				// if value from the recordset, to the ImageUrl field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("ImageUrl")) == false))
				{
					ImageUrl = rs.GetString(rs.GetOrdinal("ImageUrl"));
				}
				// if value from the recordset, to the Type field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Type")) == false))
				{
					Type = rs.GetString(rs.GetOrdinal("Type"));
				}
			}
			catch (SqlException sqlExc)
			{
				throw sqlExc;
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		
		private SqlParameter[] GetSqlParameters()
		{
			List<SqlParameter> SqlParmColl = new List<SqlParameter>();
			try
			{
				SqlParmColl.Add(SqlUtil.AddSqlParm("@ProjectImageID", ProjectImageID, SqlDbType.Int));
				SqlParmColl.Add(SqlUtil.AddSqlParm("@Title", Title, SqlDbType.NVarChar));
				SqlParmColl.Add(SqlUtil.AddSqlParm("@LinkUrl", LinkUrl, SqlDbType.NVarChar));
				SqlParmColl.Add(SqlUtil.AddSqlParm("@ImageUrl", ImageUrl, SqlDbType.NVarChar));
				SqlParmColl.Add(SqlUtil.AddSqlParm("@Type", Type, SqlDbType.NVarChar));
				return SqlParmColl.ToArray();
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		#endregion
	}
	
	public class tblProjectImageCollection : System.Collections.CollectionBase
	{
		
		[Description("Adds a new tblProjectImage to the collection.")]
		public int Add(tblProjectImage item)
		{
			int newindex = List.Add(item);
			return newindex;
		}
		
		[Description("Removes a tblProjectImage from the collection.")]
		public void Remove(tblProjectImage item)
		{
			List.Remove(item);
		}
		
		[Description("Inserts an tblProjectImage into the collection at the specified index.")]
		public void Insert(int index, tblProjectImage item)
		{
			List.Insert(index, item);
		}
		
		[Description("Returns the index value of the tblProjectImage class in the collection.")]
		public int IndexOf(tblProjectImage item)
		{
			return List.IndexOf(item);
		}
		
		[Description("Returns true if the tblProjectImage class is present in the collection.")]
		public bool Contains(tblProjectImage item)
		{
			return List.Contains(item);
		}
	}
	
	public enum tblProjectImage_Fields
	{
		
		ProjectImageID,
		
		Title,
		
		LinkUrl,
		
		ImageUrl,
		
		Type,
	}
}
